//
//  TextTableViewCell.m
//  段子
//
//  Created by dllo on 16/6/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TextTableViewCell.h"
#import "imageViewTextFieldView.h"
#import "GetRowHeightTools.h"
#import "ContentModel.h"
//#import 

@interface TextTableViewCell ()

@property(nonatomic, retain)UILabel *textCellLabel;
@property(nonatomic, retain)imageViewTextFieldView *praise;
@property(nonatomic, retain)imageViewTextFieldView *critical;
@property(nonatomic, retain)imageViewTextFieldView *comment;
@property(nonatomic, retain)UIButton *forward;


@end




@implementation TextTableViewCell

- (void)dealloc
{
    [_model release];
    [_praise release];
    [_critical release];
    [_comment release];
    [_forward release];
    [_textCellLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.textCellLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_textCellLabel];
        [_textCellLabel release];
        
        self.praise = [[imageViewTextFieldView alloc]init];
        [self.contentView addSubview:_praise];
        [_praise release];
        
        self.critical = [[imageViewTextFieldView alloc]init];
        [self.contentView addSubview:_critical];
        [_critical release];
        
        self.comment = [[imageViewTextFieldView alloc]init];
        [self.contentView addSubview:_comment];
        [_comment release];
        
        self.forward = [[UIButton alloc]init];
        [self.contentView addSubview:_forward];
        [_forward release];
        
        
    }
    return self;
    
}


-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    // label行数
    CGFloat labelHeight = [GetRowHeightTools heightWith:self.model.digest];
    self.textCellLabel.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, labelHeight);
    self.textCellLabel.numberOfLines = 0;

    
    
    // 按赞次数
    self.praise.frame = CGRectMake(10, _textCellLabel.frame.size.height + 10, 100, 40);
    self.praise.handImageView.image = [UIImage imageNamed:@"priase.png"];
    
    // 不攒次数
    self.critical.frame = CGRectMake(_praise.frame.size.width + 5, _praise.frame.origin.y, _praise.frame.size.width, _praise.frame.size.height);
    self.critical.handImageView.image = [UIImage imageNamed:@"critical.png"];
    
    // 转发次数
    self.comment.frame = CGRectMake(_critical.frame.size.width + 80, _critical.frame.origin.y, _critical.frame.size.width, _critical.frame.size.height);
    self.comment.handImageView.image = [UIImage imageNamed:@"comment.png"];

    
    
}

-(void)setModel:(ContentModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.comment.countTextField.text = [NSString stringWithFormat:@"%ld",self.model.replyCount];
    
    self.critical.countTextField.text =[NSString stringWithFormat:@"%ld", self.model.downTimes];
    self.praise.countTextField.text =[NSString stringWithFormat:@"%ld", self.model.upTimes];
    self.textCellLabel.text = self.model.digest;
    
}









//- (void)awakeFromNib {
//    // Initialization code
//}
//
//- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];
//
//    // Configure the view for the selected state
//}

@end
